//
//  RLFMDBMaker.h
//  CodeFor链式编程
//
//  Created by relax on 2017/11/16.
//  Copyright © 2017年 relax. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <FMDB.h>

/// 插叙完毕的block，用于外部回调 -> 我对外传递一个 FMResult 给你，你想咋用咋用。
typedef void (^FMResultBlock)(FMResultSet *);

@interface RLFMDBMaker : NSObject

@property (nonatomic,copy) NSString *sql;
// 数据库文件
@property (nonatomic,weak) FMDatabase *db;
// 表名
// @property (nonatomic,copy) NSString *tableName;
@property (nonatomic,assign) FMResultBlock resultBlock;

#pragma mark - 三种基本的数据格式
- (RLFMDBMaker *(^)())integer;
- (RLFMDBMaker *(^)())text;
- (RLFMDBMaker *(^)())blob; // 存储归档后的对象二进制 NSData

#pragma mark - 列属性
- (RLFMDBMaker *(^)())primaryKey;
- (RLFMDBMaker *(^)())autoincrement;
- (RLFMDBMaker *(^)())notNull;

#pragma mark - 逻辑操作
- (RLFMDBMaker *(^)(NSString *))where;
- (RLFMDBMaker *(^)())AND;
- (RLFMDBMaker *(^)())OR;

- (RLFMDBMaker *(^)(id))greateThan; // >
- (RLFMDBMaker *(^)(id))greateThanOrEqualTo; // >=
- (RLFMDBMaker *(^)(id))lessThan; // <
- (RLFMDBMaker *(^)(id))lessThanOrEqualTo; // <=
- (RLFMDBMaker *(^)(id))equalTo; // ==


/** 创建表的时候，执行列名 */
- (RLFMDBMaker *(^)(NSString *))columnName;

/** 创建表 */
- (RLFMDBMaker *(^)())create;
- (RLFMDBMaker *(^)(id))values;
- (RLFMDBMaker *(^)(NSString *))set;
- (RLFMDBMaker *(^)(id))assignment;
- (RLFMDBMaker *(^)())insert;
- (RLFMDBMaker *(^)())select;
- (RLFMDBMaker *(^)())Delete;
- (RLFMDBMaker *(^)())update;
- (void(^)(NSInteger pageIndex,NSInteger pageCount))limit;




@end
